/**
 * Description:
 *
 * Created by longyihuang on 2019/4/26
 * E-Mail: 475865662@qq.com
 */
import format from 'date-fns/format'
import {DATE_TIME_FORMAT} from '../common/js/globalContants'

export const formatFilter = {
  methods: {
    /**
     * 日期格式化
     * @param dataTime
     */
    formatDateTime (dataTime) {
      return format(dataTime, DATE_TIME_FORMAT)
    }
  }
}

export const keyEvent = {
  methods: {
    /**
     * 回车登录
     */
    keyupEnter (url, after) {
      document.onkeydown = e => {
        let body = document.getElementsByTagName('body')[0]
        if (e.keyCode === 13 && e.target.baseURI.match(url) && e.target === body) {
          after()
        }
      }
    }
  }
}
